# -*- coding: utf-8 -*-
"""
Created on Mon Oct  1 07:43:21 2018

@author: cheny
"""

#python 变量的交换
a = 10
b = 20
print(a,b)
a,b = b,a
print(a,b)

#set定义
s = set()
print(type(s))

s1 = {1,2,3,4,5,6,7} #一定要有值，否则定义出来的是字典dict
print(type(s1))
print(s1)

s2 = {} #这是一个dict
print(type(s2))

s = {"a", 4, 5, "hello", "hahaha"}
print(s)
if "hahah" in s:
    print("I am here")
else:
    print("I am not here")
    
s = {"a", 4, 5, "hello", "hahaha"}
for item in s:
    print(item, end = "\t")

s = {(1,2,3), ("a", "b", "c"), ("hha", 1, "wwww")}
for k,m,n in s:
    print(k,"--", m,"--",n)
    
print("**********************")
for k in s:
    print(k)

s = {1,2,3,4,5,666,7,9,88,76,4,3,2,555,666,3,2,1,1,1,2,3}
print(s)

ss = {i for i in s}
print(ss)

#带条件的集合内涵
ss = {i for i in s if i % 2 == 0}
print(ss)

s = {"a", 4, 5, "hello",4,"a", "hahaha"}
print(len(s))
print("******************************")
s = {"a", 4, 5, "hello", "hahaha"}
print(s)
s.add(129)
s.add("python")
print(s)
s.pop()
print(s)

s = {"a", 4, 5, "hello",4,"a", "hahaha"}
s.discard("a")
print(s)
s.discard("cheny")
print(s)
#s.remove("chenyc")


s1 = {1,2,3,4,5,6}
s2 = {5,6,7,8,9}

s_1 = s1.intersection(s2)
print(s_1)
s_2 = s1.difference(s2)
print(s_2)
s_3 = s1.union(s2)
print(s_3)
s_4 = s1.issubset(s2)
print(s_4)
s_5 = s1.issuperset(s2)
print(s_5)

s_6 = s1 and s2
s_7 = s1 - s2
s_8 = s1 or s2
print(s_6)
print(s_7)
print(s_8)

s = frozenset()
print(type(s))


#dict的创建
d = {}
print(type(d))

d = dict()
print(type(d))

d = {"one":1, "two":2, "three":3}
print(d)

d = dict({"one":1, "two":2, "three":3})
print(d)

d = dict( one=1, two=2, three=3)
print(d)

d = dict([ ("one",1), ("two",2), ("three",3)])
print(d)

d = {"one":1, "two":2, "three":3}
print(d["two"])

d = {"one":1, "two":2, "three":3}
if "two" in d:
    print("two")
if 2 in d:
    print(2)
if ("two",2) in d:
    print (("two",2))

d = {"one":1, "two":2, "three":3}
for k in d:
    print(k, d[k])
for k in d.keys():
    print(k, d[k])
for v in d.values():
    print(v)

l = [1,2,3,4]
str = "abc"
d = dict.fromkeys(l,str)
print(d)